<?php

//设置支付状态
function set_pay_status($status)
{
    switch ($status) {
        case 0:
            return '支付失败';
            break;
        case 1:
            return '已支付';
            break;
        case 2:
            return '待支付';
            break;
        case 3:
            return '已取消';
            break;
    }


}

//设置租赁状态
function set_lease_status($status)
{
    switch ($status) {
        case 0:
            return '';
            break;
        case 1:
            return '租赁中';
            break;
        case 2:
            return '交易成功';
            break;
        case 3:
            return '交易失败';
            break;
    }

}

//设置支付状态的列表样式
function set_pay_class($status)
{
    switch ($status) {
        case 0:
            return 'am-disabled';
            break;
        case 1:
            return 'am-active';
            break;
        case 2:
            return 'am-warning';
            break;
        case 3:
            return 'am-disabled';
            break;
    }
}

//设置维权订单列表样式
function set_arbitration_calss($status)
{
    switch ($status) {
        case 0:
            return 'am-warning';
            break;
        case 1:
            return 'am-success';
            break;
        case 2:
            return 'am-disabled';
            break;
        case 3:
            return 'am-disabled';
            break;
    }
}

//设置租赁订单维权状态
function set_lease_arbitration_status($status)
{
    switch ($status) {
        case 0:
            return '无';
            break;
        case 1:
            return '维权中';
            break;
        case 2:
            return '维权成功';
            break;
        case 3:
            return '维权失败';
            break;
    }
}

//设置维权订单列表的维权状态
function set_arbitration_status($status)
{
    switch ($status) {
        case 0:
            return '维权中';
            break;
        case 1:
            return '维权成功';
            break;
        case 2:
            return '维权失败';
            break;
        case 3:
            return '撤销维权';
            break;
    }
}

//设置租赁方式
function set_lease_type($type)
{
    switch ($type) {
        case 1:
            return '按小时租赁';
            break;
        case 2:
            return '按天租赁';
            break;
        case 3:
            return '按周租赁';
            break;
        case 4:
            return '按通宵租赁';
            break;
    }
}

//设置赔付状态
function set_compensate($type)
{
    switch ($type) {
        case 0:
            return '赔付';
            break;
        case 1:
            return '不赔付';
            break;
    }
}

//设置维权订单客服处理结果
function set_deal_result_status($status)
{
    switch ($status) {
        case 0:
            return '不同意维权,交易成功！';
            break;
        case 1:
            return '同意维权，退款！';
            break;
        case 2:
            return '尚未处理';
            break;
    }
}

//设置维权原因
function set_arbitration_reason($type)
{
    switch ($type) {
        case 1:
            return '异地或锁定导致无法登陆';
            break;
        case 2:
            return '账号在线或顶号导致无法正常游戏';
            break;
        case 3:
            return '账号信息与描述不符';
            break;
        case 4:
            return '密码错误导致无法登陆';
            break;
        case 5:
            return '账号被封';
            break;
        case 6:
            return '虚贝百宝箱异常';
            break;
        case 7:
            return '其他问题';
            break;
    }
}

//设置发起维权样式
function set_arbitration_class($type)
{
    switch ($type) {
        case 1:
            return '';
            break;
        case 2:
            return 'am-comment-flip';
            break;
        case 3:
            return '';
            break;
    }
}

//设置追加维权样式
function set_arbitration_add_class($type)
{
    switch ($type) {
        case 1:
            return 'am-comment-primary comment_left';
            break;
        case 2:
            return 'am-comment-success am-comment-flip comment_right';
            break;
        case 3:
            return 'am-comment-danger';
            break;
    }
}

//设置维权对象
function set_arbitration_type($type)
{
    switch ($type) {
        case 1:
            return '买方';
            break;
        case 2:
            return '卖法';
            break;
        case 3:
            return '客服';
            break;
    }
}


//设置时间格式'm-d H:i'
function set_time($time)
{
    return date('m-d H:i', strtotime($time));
}


function _curlRequest($url, $type = 'post', $querys = '')
{

    $header = array(
        'apicommkey: 99754106633f94d350db34d548d6091a',
        'caappid:1',
    );


    $ch = curl_init();
    /* cURL settings */
    if ($type == 'get') {
        if (is_array($querys)) {
            if (0 < count($querys)) {
                $sb = "";
                foreach ($querys as $itemKey => $itemValue) {
                    if (0 < strlen($sb)) {
                        $sb .= "&";
                    }
                    if (0 < strlen($itemValue) && 0 == strlen($itemKey)) {
                        $sb .= $itemValue;
                    }
                    if (0 < strlen($itemKey)) {
                        $sb .= $itemKey;
                        if (0 < strlen($itemValue)) {
                            $sb .= "=";
                            $sb .= URLEncode($itemValue);
                        }
                    }
                }
                $url .= "?";
                $url .= $sb;
            }
        }
    }
//    echo $url;exit();
    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    if ($type == 'post') {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $querys);
    }
    $result = curl_exec($ch);
    curl_close($ch);

    return $data = empty($result) ? array() : json_decode($result, true);
}